#include "scrambled_symbols.h"
#include "priv/gisusswfilesetimpl.hxx"
#include "gisusswfileset.hxx"
#include "gisusswfile.hxx"

#include <iostream>
#include <assert.h>

using namespace std;

GisusSWFileSetImpl::GisusSWFileSetImpl()
  : _container()
{
}

GisusSWFileSetImpl::GisusSWFileSetImpl(const GisusSWFileSetImpl &model)
  : _container()
{
  tContainer::const_iterator it;

  for (it=model._container.begin(); it!=model._container.end(); it++)
    {
      _container.push_back(new GisusSWFile(*(*it)));
    }
}

GisusSWFileSetImpl::~GisusSWFileSetImpl()
{
  Clear();
}

bool GisusSWFileSetImpl::Add(GisusSWFile *swfile)
{
  _container.push_back(swfile);
  return true;
}

tUInt32 GisusSWFileSetImpl::Size() const
{
  return _container.size();
}

void GisusSWFileSetImpl::Clear()
{
  tContainer::iterator it;
  for (it=_container.begin(); it!=_container.end(); it++)
    {
      delete *it;
    }
  _container.clear();
}

GisusSWFile * GisusSWFileSetImpl::operator[](tUInt32 i) 
{
  if (i>=_container.size())
    {
#if !defined(RELEASE)
      cerr<<"GisusSWFileSetImpl::operator[](tUInt32 i="<<i<<"): Index higher than available records "<<_container.size()<<"."<<endl; cerr.flush();
      assert(0);
#endif
      return 0;
    }

  return _container[i];
}

///////////////////////////////////////////////////////////////////////////////
//
///////////////////

GisusSWFileSet::GisusSWFileSet()
  : _impl(0)
{
  _impl=new GisusSWFileSetImpl();
}

GisusSWFileSet::GisusSWFileSet(const GisusSWFileSet &model)
  : _impl(0)
{
  _impl=new GisusSWFileSetImpl(*model._impl);
}

GisusSWFileSet::~GisusSWFileSet()
{
  if (_impl) delete _impl;
  _impl=0;
}


bool GisusSWFileSet::Add(GisusSWFile *swfile)
{
  return _impl->Add(swfile);
}

void GisusSWFileSet::Clear()
{
  _impl->Clear();
}

tUInt32 GisusSWFileSet::Size() const
{
  return _impl->Size();
}

GisusSWFile *GisusSWFileSet::operator[](tUInt32 i) 
{
  return (*_impl)[i];
}
